<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%response.setHeader("cache-control","public"); %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<!-- 创建考试第一步 -->
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta name="renderer" content="webkit">
	<title>考务管理</title>
	<link rel="stylesheet" type="text/css" href="<%=path%>/static/css/bootstrap.css">
	<link rel="stylesheet" type="text/css" href="<%=path%>/static/css/font/font-awesome.min.css">
	<link rel="stylesheet" type="text/css" href="<%=path%>/static/css/common.css" />
	<link rel="stylesheet" type="text/css" href="<%=path%>/static/css/examMng/core.css">
	<link rel="stylesheet" type="text/css" href="<%=path%>/static/css/examMng/exam-org-deta.css" />
	<link rel="stylesheet" type="text/css" href="<%=path%>/static/css/examMng/exam-org.css" />
	 <link type="text/css" href="<%=path %>/static/css/examMng/jquery-ui-1.8.17.custom.css" rel="stylesheet"/>
	<link type="text/css" href="<%=path %>/static/css/examMng/jquery-ui-timepicker-addon.css" rel="stylesheet"/>
	<!--bootstrap基础引用 start-->
	<script type="text/javascript" src="<%=path%>/static/jstreeview/bootstrap/jquery-3.1.1.min.js"></script>
	<script type="text/javascript" src="<%=path%>/static/jstreeview/bootstrap/bootstrap.min.js"></script>
	<!--bootstrap基础引用 end-->
	<!--bootstrap-dialog start-->
	<link rel="stylesheet" type="text/css" href="<%=path%>/static/jstreeview/plugins/bootstrap-dialog/bootstrap-dialog.min.css">
	<script type="text/javascript" src="<%=path%>/static/jstreeview/plugins/bootstrap-dialog/bootstrap-dialog.min.js"></script>
	<!--bootstrap-dialog end-->
	<script src="<%=path%>/static/js/respond.js"></script>
	<!--[if !IE]> -->
	<script type="text/javascript">
		window.jQuery || document.write("<script src='<%=path%>/static/js/jquery-2.0.3.min.js'>" + "<" + "/script>");
	</script>
	<!-- <![endif]-->

	<script type="text/javascript">
		window.jQuery || document.write("<script src='<%=path%>/static/js/jquery-1.9.1.min.js'>" + "<" + "/script>");
	</script>

</head>

<body>

<jsp:include page="../head.jsp" flush="true"/>
<div class="main-container albox-pad-top padingtop0">
	<div class="panel container body-box">
		<div class="panel-heading col-lg-12 col-md-12  top-brgclr" style="height: 70px; background: #4c4ca6;">
			<c:choose>
				<c:when test="${label eq 'edit' }">
					<p class=" col-lg-10 col-md-10 col-sm-10 color-fff">编辑人员</p>
				</c:when>
				<c:otherwise>
					<p class=" col-lg-10 col-md-10 col-sm-10 color-fff">新增人员</p>
				</c:otherwise>
			</c:choose>
			<a class="color-fff floatrit aahover fontweight400" href="<%=path%>/sys/index" ><span class="glyphicon glyphicon-arrow-left "></span> 返回</a>
		</div>
		<div class="panel-body minheight" style="min-height: 0px;">
			<div class=" borderbottom">
			</div>
			<!--
                作者：306794978@qq.com
                时间：2016-06-22
                描述：第一步开始
            -->
			<div id="stypediv1" class=" form-box col-lg-12 col-md-12 col-sm-12 stype1displaynone2" style="min-height: 360px;">
				<form class="form-inline col-lg-12 col-md-12 col-sm-12">
					<div class="form-group col-lg-12 col-md-12 col-sm-12 padding-0">
						<div class="input-group-box col-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">编号</div>
								<c:choose>
									<c:when test="${label eq 'edit' }">
										<input type="text" id="identifier" class="form-control" value="${user.identifier }" id="text1"  />
									</c:when>
									<c:otherwise>
										<input type="text" id="identifier" class="form-control" maxlength="30" value="" placeholder="请输入编号" id="text1"  />
									</c:otherwise>
								</c:choose>

							</div>
						</div>
						<div class="input-group-box col-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">姓名</div>
								<c:choose>
									<c:when test="${label eq 'edit' }">
										<input type="text" class="form-control" value="${user.name }" id="username" maxlength="30" />
									</c:when>
									<c:otherwise>
										<input type="text" class="form-control" value="" id="username" placeholder="请输入姓名" maxlength="30" />
									</c:otherwise>
								</c:choose>
							</div>
						</div>
						<div class="input-group-box col-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">单位</div>
								<select class="form-control" id="unit" name="jiankong" >
									<option value="0">请选择单位</option>
									<c:forEach items="${unit }" var="unit">
										<option value="${unit.id }" <c:if test="${label eq 'edit' && user.unit_id eq unit.id }">selected</c:if>>${unit.name }</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="input-group-box col-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">角色</div>
								<select class="form-control" id="role" name="jiankong" onchange="changeRole();">
									<option value="0">请选择角色</option>
									<c:forEach items="${role }" var="role">
										<option value="${role.id }"<c:if test="${label eq 'edit' && role_id eq role.id }">selected</c:if>>${role.name }</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div id="proDiv" class="input-group-box col-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">专业</div>
								<select class="form-control" id="pro" name="pro"  onchange="change()">
									<option value="0">请选择专业</option>
									<c:forEach items="${pro}" var="pro">
										<option value="${pro.id }"<c:if test="${label eq 'edit' && user.pro_id eq pro.id }">selected</c:if>>${pro.name }</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div id="rankDiv" class="input-group-box col-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">级别</div>
								<select class="form-control" id="rank" name="rank" >
									<option value="0">请选择级别</option>
									<c:forEach items="${ranks }" var="rank">
										<option value="${rank.id }"<c:if test="${label eq 'edit' && user.rank_id eq rank.id }">selected</c:if>>${rank.name }</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="input-group-box col-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">证件号</div>
								<c:choose>
									<c:when test="${label eq 'edit' }">
										<input type="text" class="form-control" maxlength="30" value="${user.account }" id="account" placeholder="" disabled />
									</c:when>
									<c:otherwise>
										<input type="text" class="form-control" maxlength="30" value="" id="account" placeholder="请输入证件号"/>
									</c:otherwise>
								</c:choose>
							</div>
						</div>
						<div class="input-group-box col-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">密码</div>
								<c:choose>
									<c:when test="${label eq 'edit' }">
										<input id="resetpass" type="text" class="form-control" value="                   点击重置为初始密码" id="password" />
									</c:when>
									<c:otherwise>
										<input type="text" class="form-control" value="初始密码" id="password" placeholder="" onBlur="textBlur(this)"  onFocus="textFocus(this)" disabled />
									</c:otherwise>
								</c:choose>
							</div>
						</div>

						<div class="input-group-box col-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">士兵号</div>
								<c:choose>
									<c:when test="${label eq 'edit' }">
										<input type="text" class="form-control" value="${user.soldierId }" id="soldierId" maxlength="30" />
									</c:when>
									<c:otherwise>
										<input type="text" class="form-control" value="" id="soldierId" placeholder="请输入士兵号" maxlength="30" />
									</c:otherwise>
								</c:choose>
							</div>
						</div>

						<div class="input-group-box col-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">身份证号</div>
								<c:choose>
									<c:when test="${label eq 'edit' }">
										<input type="text" class="form-control" value="${user.identityId }" id="identityId" maxlength="30" />
									</c:when>
									<c:otherwise>
										<input type="text" class="form-control" value="" id="identityId" placeholder="请输入身份证号" maxlength="30" />
									</c:otherwise>
								</c:choose>
							</div>
						</div>

						<div class="input-group-box col-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">文化程度</div>
								<select class="form-control" id="education" name="education">
									<option value="0">请选择文化</option>
									<option value="小学"<c:if test="${user.education eq '小学' }">selected</c:if>>小学</option>
									<option value="初中"<c:if test="${user.education eq '初中' }">selected</c:if>>初中</option>
									<option value="高中"<c:if test="${user.education eq '高中' }">selected</c:if>>高中</option>
									<option value="中专"<c:if test="${user.education eq '中专' }">selected</c:if>>中专</option>
									<option value="大专"<c:if test="${user.education eq '大专' }">selected</c:if>>大专</option>
									<option value="本科"<c:if test="${user.education eq '本科' }">selected</c:if>>本科</option>
									<option value="硕士"<c:if test="${user.education eq '硕士' }">selected</c:if>>硕士</option>
									<option value="博士"<c:if test="${user.education eq '博士' }">selected</c:if>>博士</option>
								</select>
							</div>
						</div>

						<div class="input-group-box col-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">性别</div>
								<select class="form-control" id="sex" name="sex">
									<option value="0">请选择性别</option>
								<option value="男"<c:if test="${user.sex eq '男' }">selected</c:if>>男</option>
								<option value="女"<c:if test="${user.sex eq '女' }">selected</c:if>>女</option>
								</select>

							</div>
						</div>

						<div class="input-group-box col-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">现部别</div>
								<c:choose>
									<c:when test="${label eq 'edit' }">
										<input type="text" class="form-control" value="${user.position }" id="position" maxlength="30" />
									</c:when>
									<c:otherwise>
										<input type="text" class="form-control" value="" id="position" placeholder="请输入现部别" maxlength="30" />
									</c:otherwise>
								</c:choose>
							</div>
						</div>

						<div class="input-group-box col-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">军衔</div>
								<c:choose>
									<c:when test="${label eq 'edit' }">
										<input type="text" class="form-control" value="${user.armyRank }" id="armyRank" maxlength="30" />
									</c:when>
									<c:otherwise>
										<input type="text" class="form-control" value="" id="armyRank" placeholder="请输入军衔" maxlength="30" />
									</c:otherwise>
								</c:choose>
							</div>
						</div>

						<div class="input-group-box col-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">从事专业</div>
								<c:choose>
									<c:when test="${label eq 'edit' }">
										<input type="text" class="form-control" value="${user.specialty }" id="specialty" maxlength="30" />
									</c:when>
									<c:otherwise>
										<input type="text" class="form-control" value="" id="specialty" placeholder="请输入从事专业" maxlength="30" />
									</c:otherwise>
								</c:choose>
							</div>
						</div>

						<div class="input-group-box col-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">申报专业</div>
								<c:choose>
									<c:when test="${label eq 'edit' }">
										<input type="text" class="form-control" value="${user.workCategory }" id="workCategory" maxlength="30" />
									</c:when>
									<c:otherwise>
										<input type="text" class="form-control" value="" id="workCategory" placeholder="请输入申报专业" maxlength="30" />
									</c:otherwise>
								</c:choose>
							</div>
						</div>

						<div class="input-group-box col-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">申报等级</div>
								<c:choose>
									<c:when test="${label eq 'edit' }">
										<input type="text" class="form-control" value="${user.declarelevel }" id="declarelevel" maxlength="30" />
									</c:when>
									<c:otherwise>
										<input type="text" class="form-control" value="" id="declarelevel" placeholder="请输入申报等级" maxlength="30" />
									</c:otherwise>
								</c:choose>
							</div>
						</div>

						<div class="input-group-box col-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">工作年限</div>
								<c:choose>
									<c:when test="${label eq 'edit' }">
										<input type="text" class="form-control" value="${user.serviceYear }" id="serviceYear" maxlength="30" />
									</c:when>
									<c:otherwise>
										<input type="text" class="form-control" value="" id="serviceYear" placeholder="请输入工作年限" maxlength="30" />
									</c:otherwise>
								</c:choose>
							</div>
						</div>

						<div class="input-group-box col-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">出生日期</div>
								<c:choose>
									<c:when test="${label eq 'edit' }">
										<input name="birthdate" type="text" id="ui_timepicker" class="ui_timepicker form-control" value="${user.birthdate }" placeholder="请输入出生日期" maxlength="30" autocomplete="off"/>
									</c:when>
									<c:otherwise>
									<input name="birthdate" type="text" id="ui_timepicker" class="ui_timepicker form-control" placeholder="请输入出生日期" maxlength="30" autocomplete="off"/>
									</c:otherwise>
								</c:choose>
							</div>
						</div>

						<div class="input-group-box col-lg-6 col-md-6 col-sm-6">
							<div class="input-group col-lg-12 col-md-12 col-sm-12">
								<div class="input-group-addon width150">入伍年月</div>
								<c:choose>
									<c:when test="${label eq 'edit' }">
									<input name="addArmy" type="text" id="ui_timepicker2" class="ui_timepicker form-control" value="${user.addArmy }" maxlength="30" autocomplete="off"/>
									</c:when>
									<c:otherwise>
										<input name="addArmy" type="text" id="ui_timepicker2" class="ui_timepicker form-control" placeholder="请输入入伍年月" maxlength="30" autocomplete="off"/>
									</c:otherwise>
								</c:choose>
							</div>
						</div>




					</div>
				</form>
			</div>
		</div>
	</div>
	<div class="stypebox">
		<div  class=" form-submit floatleft" >
			<div id="stypeback" class="btn btn-default  margintopbom "disabled="disabled">
				<i class="glyphicon glyphicon-arrow-left  lineheightx" style="margin-left:0;"></i> <span class="">取消</span>
			</div>
		</div>
		<div class="form-submit floatrit">
			<div  id="validation" class="btn btn-info margintopbom">
				<span style="color: #FFFFFF">确定 </span> <span class="glyphicon glyphicon-arrow-right  lineheightx" style="margin-right:0; color: #FFFFFF"></span>
			</div>
		</div>
	</div>


	<!--body end-->
	<script type="text/javascript" src="<%=path%>/static/js/jquery-ui.min.js"></script>
	<script type="text/javascript" src="<%=path%>/static/js/jquery.selectlist.js" ></script>
	<script type="text/javascript" src="<%=path%>/static/js/global.js"></script>
	<script type="text/javascript" src="<%=path%>/static/js/tooltip.js"></script>
	<script type="text/javascript" src="<%=path%>/static/js/examMng/datetime.js"></script>
	<script type="text/javascript" src="<%=path%>/static/js/examMng/jquery-ui-timepicker-addon.js"></script>
	<script type="text/javascript" src="<%=path%>/static/js/examMng/jquery-ui-timepicker-zh-CN.js"></script>
</div>
</div>
</body>
<script type="text/javascript">
	$(function(){
		var role  = '${roleId}'
		if(role=="3"){
			$("#proDiv").css("display","block");
			$("#rankDiv").css("display","block");
		}else{
			$("#proDiv").css("display","none");
			$("#rankDiv").css("display","none");
		}


		/**********************考试时间插件初始化*******************************************/
	    $("#ui_timepicker").datepicker({
	    	changeMonth: true,
	        changeYear: true,
	        yearRange:"1919:2050"
	    })
	    $("#ui_timepicker2").datepicker({
	    	changeMonth: true,
	        changeYear: true,
	        yearRange:"1919:2050"
	    })
	    /****************************************************************************/
		$('#topMain').children().eq(0).addClass('active'); // 追加样式;

		//出生年月
		//入伍年月

		//人员管理
		if (${role eq 'master'}) {
			$('#topMain').children().eq(0).addClass('active'); // 追加样式;
			$('#topMain').children().eq(0).children().attr('href', '#');
		} else if (${role eq 'trainee'}) {
			$('#topMain').children().eq(0).addClass('active'); // 追加样式;
			$('#topMain').children().eq(0).children().attr('href', '#');
		} else {
			$('#topMain').children().eq(0).addClass('active'); // 追加样式;
			// $('#topMain').children().eq(0).children().attr('href', '#');
		}

	})
	var titleType = 0;
	//select下拉框模拟
	$("#validation").click(function(){
		var username = $("#username").val().replace(/(^\s*)|(\s*$)/g, "");
		var identifier = $("#identifier").val().replace(/(^\s*)|(\s*$)/g, "");
		var account = $("#account").val().replace(/(^\s*)|(\s*$)/g, "");
		var unit_id = $("#unit").val();
		var pro_id = $("#pro").val();
		var rank_id = $("#rank").val();
		var role = $("#role").val();


		var soldierId = $("#soldierId").val();
		var identityId = $("#identityId").val();
		var education = $("#education").val();
		var sex = $("#sex").val();
		var position = $("#position").val();
		var armyRank = $("#armyRank").val();
		var specialty = $("#specialty").val();
		var workCategory = $("#workCategory").val();
		var declarelevel = $("#declarelevel").val();
		var serviceYear = $("#serviceYear").val();
		var birthdate = $(" input[ name='birthdate' ] ").val();
		var addArmy = $(" input[ name='addArmy' ] ").val();

		if(identifier==""){
			BootstrapDialog.confirm({
				title : '提示',
				message : '编号不能为空',
				size : BootstrapDialog.SIZE_SMALL,
				type : BootstrapDialog.TYPE_DEFAULT,
				closable : true,
				btnCancelLabel : '取消',
				btnOKLabel : '确定'
			});
			return
		}
		if(username==""){
			BootstrapDialog.confirm({
				title : '提示',
				message : '姓名不能为空',
				size : BootstrapDialog.SIZE_SMALL,
				type : BootstrapDialog.TYPE_DEFAULT,
				closable : true,
				btnCancelLabel : '取消',
				btnOKLabel : '确定'
			});
			return;
		}
		if(unit_id==0){
			BootstrapDialog.confirm({
				title : '提示',
				message : '请选择单位',
				size : BootstrapDialog.SIZE_SMALL,
				type : BootstrapDialog.TYPE_DEFAULT,
				closable : true,
				btnCancelLabel : '取消',
				btnOKLabel : '确定'
			});
			return;
		}
		if(role==0){
			BootstrapDialog.confirm({
				title : '提示',
				message : '请选择角色',
				size : BootstrapDialog.SIZE_SMALL,
				type : BootstrapDialog.TYPE_DEFAULT,
				closable : true,
				btnCancelLabel : '取消',
				btnOKLabel : '确定'
			});
			return;
		}
		if(account==""){
			BootstrapDialog.confirm({
				title : '提示',
				message : '证件号不能为空',
				size : BootstrapDialog.SIZE_SMALL,
				type : BootstrapDialog.TYPE_DEFAULT,
				closable : true,
				btnCancelLabel : '取消',
				btnOKLabel : '确定'
			});
			return
		}

		$.ajax({
			url : '<%=basePath%>person/save',
			data: {
				id: '${user.id}',
				identifier: identifier,
				name: username,
				account:account,
				unit_id:unit_id,
				pro_id:pro_id,
				rank_id:rank_id,
				role:role,
				soldierId:soldierId,
				identityId:identityId,
				education:education,
				sex:sex,
				position:position,
				armyRank:armyRank,
				specialty:specialty,
				workCategory:workCategory,
				declarelevel:declarelevel,
				serviceYear:serviceYear,
				birthdate:birthdate,
				addArmy:addArmy
			},
			dataType : "json",
			success : function(data) {
				BootstrapDialog.confirm({
					title : '提示',
					message : data.msg,
					size : BootstrapDialog.SIZE_SMALL,
					type : BootstrapDialog.TYPE_DEFAULT,
					closable : true,
					btnCancelLabel : '取消',
					btnOKLabel : '确定'
				});
				window.location.href = "<%=path%>/sys/index";
			}
		});
	});

	$("#resetpass").click(function () {
		var id = '${user.id}';
		$.post("<%=path%>/person/resetpass",{id:id},function () {
			BootstrapDialog.confirm({
				title : '提示',
				message : '重置密码成功',
				size : BootstrapDialog.SIZE_SMALL,
				type : BootstrapDialog.TYPE_DEFAULT,
				closable : true,
				btnCancelLabel : '取消',
				btnOKLabel : '确定'
			});
		})
	})
	function changeRole(){
		var role  = $("#role").val();
		role = role.trim();
		if(role=="3"){
			$("#proDiv").css("display","block");
			$("#rankDiv").css("display","block");
		}else{
			$("#proDiv").css("display","none");
			$("#rankDiv").css("display","none");
		}
	}

	function change(){
		var proId = $("#pro").val();
		$.ajax({
			type:"POST",
			url:"<%=basePath %>depository/getRanksByPro",
			data:{"proId":proId},
			success:function(data){
				if(data.status==1){
					var rankArr = data.rankList;
					//清空
					$("#rank").find("option").remove();
					//将要显示的内容展现
					$("#rank").append("<option value='0'>请选择级别</option>") ;
					for(var i = 0;i<rankArr.length;i++){
						$("#rank").append("<option value='"+rankArr[i].id+"'>"+rankArr[i].name+"</option>") ;
					}
				}else {
					$("#rank").find("option").remove();
					$("#rank").append("<option value='0'>请选择级别</option>")
				}
			}
		})
	}
	

</script>

</html>